<template>
  <div>
    <headercom></headercom>
    <div class="bcg left_bcg bjdhed">
      <div class="hedlist">
        <div class="head_box">
          <div class="headbtn">
            <a-button type="primary" @click="addnewbjd">新增报价单</a-button>
          </div>
          <div class="sele">
            <a-select
              show-search
              placeholder="请输入客户名称"
              option-filter-prop="children"
              style="width: 200px"
              :filter-option="filterOption"
              @focus="handleFocus"
              @blur="handleBlur"
              @change="khmcchan"
              @search='khmcsec'
              allowClear
            >
              <a-icon slot="suffixIcon" type="search" :style="{ fontSize: '16px'}"  />
              <a-select-option
                :value="item.DWMC"
                v-for="(item, i) in khmclist"
                :key="i"
              >{{item.DWMC}}</a-select-option>
            </a-select>

            <!-- <a-auto-complete v-model="khmc_keywords" :data-source="sccjcData"  class="global-search sele_input"   @search="searchqxlist" @select="searchqxlistSelect" size="large" placeholder="请输入客户名称" > -->
            <!-- <a-auto-complete
              v-model="khmc_keywords"
              class="global-search sele_input"
              @search="searchqxlist"
              size="large"
              placeholder="请输入客户名称"
            >
              <a-input>
                <a-button slot="suffix" style="margin-right: -12px" class="search-btn" size="large">
                  <a-icon type="search" />
                </a-button>
              </a-input>
            </a-auto-complete>-->
          </div>
              <div class="sele">
            <a-input
              placeholder="请输入合同单号"
              v-model="keywords"
              @change="searchqxlist"
              class="sele_input"
            />
            <a-icon type="search" class="sear_ico" />
          </div>
          <div class="sele">
            <span>归属公司：</span>
            <a-select v-model="gsbm_val" disabled @change="handleGsbmChange" class="sele_input">
              <a-select-option :value="gs" v-for="(gs,i) in bjdzzdata" :key="i">{{gs}}</a-select-option>
            </a-select>
          </div>
        </div>
      </div>
      <div class="bjdzz_box">
        <a-table
          :columns="columns"
          :data-source="bjdlist"
          @change="getbjdList"
          :pagination="pagination"
          :rowKey="(record,index)=>{return index}"
         :scroll="{ x: 1600 }"
         tableLayout='fixed'

        >
          <a slot="name" slot-scope="text">{{ text }}</a>
          <template slot="bjdh" slot-scope="text, record,">
            <div class="ymInfo_yc yc">
              <a-tooltip placement="topLeft" :title="record.bjdh">{{record.bjdh}}</a-tooltip>
            </div>
          </template>
          <template slot="totalNum" slot-scope="text, record, index">
            <div>
              <span style="color:#40a9ff;">{{text}}</span>
            </div>
          </template>
          <!-- <template slot="zdr" slot-scope="text, record, index">
            <div>
              <span >{{zdr_name}}</span>
            </div>
          </template> -->
          <template slot="operation" slot-scope="text, record, index">
            <div class="editable-row-operations">
              <a-popconfirm title="确定要删除吗?" @confirm="() => alldel(record,record.key)">
                <a href="javascript:;" class="del">整单删除</a>
              </a-popconfirm>
              <a href="javascript:;" class="del" @click="editbjdlist(record,index,'edit_ok')">修改</a>
              <!-- <a href="javascript:;" class="del" @click="actionbtn(record,index)">执行</a> -->
              <a-popconfirm title="确定要执行吗?" @confirm="() => actionbtn(record,index)">
                <a href="javascript:;" class="del">执行</a>
              </a-popconfirm>
              <a href="javascript:;" class="del" @click="print(record,index,'edit_ok')">打印</a>
            </div>
          </template>
        </a-table>
      </div>
    </div>
    <div class="print_box" v-if="print_flag">
      <print></print>
    </div>
    <div class="addnew_box" v-if="addnew_flag">
      <div class="bjd_tk">
        <div class="close" @click="close">
          <a-icon type="close" />
        </div>
        <div class="ant-tabs-bar">
          <div class="bjd_tit">
            <span class="cz_title" v-if="zzl_val">报价单修改</span>
            <span class="cz_title" v-else>新增报价单</span>
            <span class="cz_title_border"></span>
          </div>
        </div>
        <div class="inpt_box" v-show="sp_inp_flag">
          <ul>
            <li>
              <span class="inp_tit">发票类型：</span>
              <a-select :value="zzl_val" style="width: 76%" placeholder="请选择" @change="zzsChange">
                <a-select-option v-for="(item, i) in sl_data" :key="i" :value="item.mc">{{item.mc}}</a-select-option>
                <!-- <a-select-option value="增值税专用发票">增值税专用发票</a-select-option> -->
              </a-select>
            </li>
            <li>
              <span class="inp_tit">税率：</span>
              <!-- <a-input placeholder='请输入'></a-input> -->
              <a-input-number
              disabled
                style="width: 76%"
                :default-value="100"
                :min="0"
                :max="100"
                placeholder="请输入"
                v-model="sl_val"
                :formatter="value => `${value}%`"
                :parser="value => value.replace('0%', '')"
                @change="numberChange"
              />
            </li>
            <li>
              <span class="inp_tit">客户名称：</span>
              <a-select
                show-search
                placeholder="必选"
                option-filter-prop="children"
                style="width: 76%"
                :value="khmckews_val"
                :filter-option="filterOption"
                @focus="handleFocus"
                @blur="handleBlur"
                @change="khmcChange"
                @search="khmcSearch"
                allowClear
              >
                <a-select-option
                  :value="item.DWMC"
                  v-for="(item, i) in khmclist"
                  :key="i"
                  @click="khmctap(item.DWBH,item.RWR)"
                >{{item.DWMC}}</a-select-option>
              </a-select>
            </li>
            <li>
              <span class="inp_tit">任务人：</span>
              <a-select
                :value="rwr_val"
                allowClear
                placeholder="请选择"
                style="width: 76%"
                @change="rwrChange"
              >
                <a-select-option v-for="(item, i) in rwr" :key="i" :value="item">{{item}}</a-select-option>
              </a-select>
            </li>
            <!-- <li>
              <span class="inp_tit">备注信息：</span>
              <a-textarea
                class="textarea"
                style="    vertical-align: middle; width: 300px"
                placeholder="请填写详细信息"
                v-model="bzxx"
              ></a-textarea>
            </li>-->
          </ul>
        </div>
        <div class="spxx_box" v-show="sp_inp_flag">
          <p class="tit_p">
            <span>商品信息</span>
          </p>
          <div class="spxx_list_data">
            <ul>
              <li @click="selesplist" v-if="!$store.state.selectedrecord.length">
                <p class="zw_p">暂无商品</p>
              </li>
              <li
                :style="item.num&&item.money!=0?'':'border:1px solid red;'"
                v-for="(item, i) in $store.state.selectedrecord"
                :key="i"
              >
                <p class="yc ymInfo_yc">
                  <!-- <span v-show="spxx_index==i?false:true">{{item.xl}}</span> -->
                    <!-- v-show="spxx_index==i?true:false" -->
                  <a-input
                    style="width:100%"
                    type="text"
                    v-model="item.xl"
                    name
                    id
                  ></a-input>
                </p>
                <div class="center">
                  <P>
                    <!-- <span v-show="spxx_index==i?false:true">{{item.sccjc}}</span> -->
                    <a-input
                      class="sccjc_yc yc"
                      style="width:90%"
                      type="text"
                      v-model="item.sccjc"
                    ></a-input>
                  </P>
                </div>
                <div class="center fot_mon">
                  <p>
                    <span style="color:#ccc">单价：</span>
                    <!-- <span v-show="spxx_index==i?false:true">{{item.money}}</span> -->
                    <a-input-number
                      :min="0"
                      style="width:50%"
                      type="text"
                      v-model="item.money"
                    />元
                  </p>
                  <p class="num_p">
                    <span style="color:#ccc">数量：</span>
                    <!-- <span v-show="spxx_index==i?false:true">{{item.num}}</span> -->
                    <a-input-number
                      :min="0"
                      id="inputNumber"
                      style="width:35%"
                      type="text"
                      v-model="item.num"
                      name
                    />

                    <!-- <span v-show="spxx_index==i?false:true">{{item.jldw}}</span> -->

                    <a-select
                      show-search
                      placeholder="Select a person"
                      option-filter-prop="children"
                      style="width: 35%"
                      v-model="item.jldw"
                      :filter-option="filterOption"
                      @focus="handleFocus"
                      @blur="handleBlur"
                      @change="jldwChange"
                    >
                      <a-select-option
                        v-for="(item, i) in jldwlist"
                        :key="i"
                        :value="item.mc"
                      >{{item.mc}}</a-select-option>
                    </a-select>
                  </p>
                </div>
                <div class="center cenedit">
                  <!-- <span v-show="spxx_index==i?false:true" class="xx_ico" @click="editspxx(item,i)">
                    <span class="cz_style">修改</span>
                  </span> -->
                  <span  @click="delxx(item,i)" class="xx_ico">
                    <!-- <a-icon type="delete" /> -->
                    <span class="cz_style">删除</span>
                  </span>
                  <!-- <span v-show="spxx_index==i?true:false" class="xx_ico" @click="savsub(item,i)">
                    <span class="cz_style">保存</span>
                  </span> -->
                  <!-- <span v-show="spxx_index==i?true:false" class="xx_ico" @click="cansav(item,i)">
                    <span class="cz_style">取消</span>
                  </span> -->
                </div>
              </li>
            </ul>
            <p class="click_spxx" >
              <span @click="selesplist"><a-icon type="bars" class="bars_ico" />选择商品</span>
            </p>
          </div>
        </div>
        <div class="textarea_box">
          <ul>
            <li>
              <span class="inp_tit">备注信息：</span>
              <!-- <a-input style="width: 300px" placeholder='请填写详细信息'></a-input> -->
              <a-input
                class="textarea"
                style="    vertical-align: middle; "
                placeholder="请填写详细信息"
                v-model="bzxx"
              ></a-input>
            </li>
          </ul>
        </div>
        <div class="sub_btn">
          <a-button @click="close">取消</a-button>
          <a-button type="primary" @click="savfrom">保存</a-button>
        </div>
        <div class v-if="spxx_flag">
          <spxx></spxx>
        </div>
      </div>
    </div>
    <rightnav></rightnav>
  </div>
</template>

<script>
import headercom from "../../header-comm/header.vue";
import spxx from "./spxx.vue";
import rightnav from "../rightnav.vue";
import print from "./print/print.vue";

import qs from "qs";
const columns = [
  {
    title: "单据编号",
    dataIndex: "bjdh",
    key: "bjdh",
    scopedSlots: { customRender: "bjdh" }
  },
  {
    title: "制单人",
    dataIndex: "zdr",
    key: "zdr",
    scopedSlots: { customRender: "zdr" }

  },
  {
    title: "任务人",
    dataIndex: "rwr",
    key: "rwr"
  },
  {
    title: "制单日期",
    dataIndex: "zdrq",
    key: "zdrq"
  },
  {
    title: "客户名称",
    dataIndex: "dwmc",
    key: "dwmc"
  },
  {
    title: "总数量",
    dataIndex: "totalNum",
    key: "totalNum",
    scopedSlots: { customRender: "totalNum" }
  },
  {
    title: "总金额",
    dataIndex: "totalPrice",
    key: "totalPrice"
  },
  {
    title: "操作",
    dataIndex: "operation",
    scopedSlots: { customRender: "operation" },
     fixed:'right',
     
    width:280
  }
];

var bjdlist = [];
export default {
  data() {
    return {
      bjdlist,
      columns,
      khmc_keywords: "",
      keywords:'',
      gsbm: "",
      pagination: {
        defaultPageSize: 10,
        showTotal: total => `共 ${total} 条数据`,
        total: 0,
        current: 1
      },
      addnew_flag: false,
      spxx_flag: false,
      sp_inp_flag: true,
      dataSource: ["Burns Bay Road", "Downing Street", "Wall Street"],
      zzl_val: undefined,
      sl_val: 0,
      rwr: "",
      zdr_name:sessionStorage.getItem("zdr"),
      khmclist: "",
      khmckews: "",
      khmckews_val: undefined,
      spxx_index: "1-1",
      jldwlist: "",
      num_val: 0,
      money_val: 0,
      bzxx: "",
      rwr_val: undefined,
      dwbh: "",
      edit_ok: "",
      publicData: "",
      print_data: "",
      print_flag: false,
      bjdzzdata: "",
      gsbm_val: "查所有",
      sl_data: ""
    };
  },

  methods: {
    numChange(value) {
      console.log("changed", value);
    },
    searchqxlist() {
      console.log(this.keywords);
      this.getbjdList(this.pagination);
    },
    addnewbjd() {
      this.addnew_flag = true;
      this.edit_ok = "no";
      this.zzl_val = undefined;
      this.publicData = "";
      this.sl_val = 0;
      this.khmckews_val = undefined;
      this.dwbh = "";
      this.rwr_val = undefined;
      this.bzxx = "";
      this.$store.state.selectedrecord = [];
      this.bjdh = "";
    },
    getbjdList(pagination) {
      console.log(pagination);
      this.pagination.current = pagination.current;
      var bjdzzdata = this.bjdzzdata + ",";
      console.log(bjdzzdata);
      this.axios
        .post(
          this.$store.state.baseurl + "/wxapi/smt_bjdList.php",
          qs.stringify({
            page: this.pagination.current,
            pageSize: this.pagination.defaultPageSize,
            keywords: this.keywords,
            khmc:this.khmc_keywords,
            token: sessionStorage.getItem("smt_token"),
            rwr: "",
            rwrall: sessionStorage.getItem("xsuser"),
            gsbm: this.gsbm_val,
            allbm: bjdzzdata
            // rwr: this.rwr_val
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 103) {
            this.bjdlist = res.data.result.resDate;
            this.pagination.total = res.data.result.totalDataNum;
          } else {
            this.bjdlist = [];
          }
        });
    },
    alldel(item, key) {
      this.axios
        .post(
          this.$store.state.baseurl + "/wxapi/smt_bjddelete.php",
          qs.stringify({
            bjdh: item.bjdh,
            token: sessionStorage.getItem("smt_token")
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 103) {
            this.getbjdList(this.pagination);
            this.$notification["success"]({
              message: "成功",
              description: res.data.msg
            });
          } else {
            this.$notification["error"]({
              message: "失败",
              description: res.data.msg
            });
          }
        });
    },
    zzsChange(value) {
      console.log(`selected ${value}`);
      this.zzl_val = value;
      if (value == "增值税普通发票") {
        this.sl_val = 3;
      } else if (value == "增值税专用发票") {
        this.sl_val = 13;
      } else {
        this.sl_val = 0;
      }
    },
    // 公司编码选择
    handleGsbmChange(value) {
      console.log(value);
      this.gsbm_val = value;
      this.getbjdList(this.pagination);

      // sessionStorage.setItem("gsbm", this.gsbm);
      // this.onSearch();
    },

    numberChange(value) {
      console.log("changed", value);
    },
    khmcChange(value) {
      console.log(`selected ${value}`);
      this.khmckews_val = value;
      // this.getkhdacx(1);
    },
    khmctap(dwbh,rwr) {
      this.dwbh = dwbh;
      this.rwr_val=rwr.trim()
      console.log(rwr)
    },

    khmcSearch(value) {
      console.log(`selected ${value}`);
      this.khmckews = value;
      this.getkhdacx(1);
    },
    rwrChange(value) {
      this.rwr_val = value;
      console.log(`selected ${value}`);
    },
    handleBlur() {
      console.log("blur");
      this.khmckews = "";
      this.getkhdacx(1);
    },
    handleFocus() {
      console.log("focus");
    },
    filterOption(input, option) {
      return (
        option.componentOptions.children[0].text
          .toLowerCase()
          .indexOf(input.toLowerCase()) >= 0
      );
    },
    close() {
      this.addnew_flag = false;
      this.$store.state.selectedrecord = [];
      this.spxx_index = "1-1";
      this.getbjdList(this.pagination);
    },
    editspxx(item, index) {
      console.log(item, index);
      this.num_val = item.num;
      this.money_val = item.money;
      this.spxx_index = index;
    },
    savsub(item, index) {
      console.log(item, index);

      if (this.edit_ok == "edit_ok") {
        if (item.ID_NUM == "" || item.ID_NUM == undefined) {
          this.$store.state.selectedrecord[index].num = this.num_val;
          this.$store.state.selectedrecord[index].money = this.money_val;
          this.$store.state.selectedrecord[index] = item;
          this.spxx_index = "1-1";
        } else {
          this.axios
            .post(
              "https://yb.bearing.cn/wxapi/smt_bjdEditDetails.php",
              qs.stringify({
                id_num: item.ID_NUM,
                xl: item.xl,
                sccjc: item.sccjc,
                money: this.money_val,
                num: this.num_val,
                jldw: item.jldw,
                token: sessionStorage.getItem("smt_token")
              })
            )
            .then(res => {
              console.log(res);
              if (res.data.code == 103) {
                this.$store.state.selectedrecord[index].num = this.num_val;
                this.$store.state.selectedrecord[index].money = this.money_val;
                this.$store.state.selectedrecord[index] = item;
                this.spxx_index = "1-1";
                // this.$notification["success"]({
                //   message: "成功",
                //   description: res.data.msg
                // });
              } else {
                // this.$notification["error"]({
                //   message: "失败",
                //   description: res.data.msg
                // });
              }
            });
        }
      } else {
        this.$store.state.selectedrecord[index].num = this.num_val;
        this.$store.state.selectedrecord[index].money = this.money_val;
        this.$store.state.selectedrecord[index] = item;
        this.spxx_index = "1-1";
      }
    },
    cansav(item, index) {
      this.spxx_index = "1-1";
      this.$store.state.selectedrecord[
        index
      ] = this.$store.state.selectedrecord[index];
    },
    delxx(item, index) {
      console.log(this.$store.state.selectedrecord);

      for (var i = 0; i < this.$store.state.selectedrecord.length; i++) {
        if (item.id == this.$store.state.selectedrecord[i].id) {
          console.log(i);
          this.$store.state.selectedrecord.splice(i, 1);
        }
      }
    },
    savfrom() {
      // for (var i = 0; i < this.$store.state.selectedrecord.length; i++) {
      //   if (
      //     this.$store.state.selectedrecord[i].money == "" ||
      //     this.$store.state.selectedrecord[i].money == 0 ||
      //     this.$store.state.selectedrecord[i].money == null
      //   ) {
      //     alert("请填写商品单价、数量");
      //     return false;
      //   }
      // }

      // console.log(this.zzl_val); //增值发票
      // console.log(this.sl_val); //增值率
      // console.log(this.khmckews_val); //客户名称
      // console.log(this.rwr_val); //任务人
      // console.log(this.bzxx); //备注
      // console.log(this.$store.state.selectedrecord);
      var bjData = JSON.stringify(this.$store.state.selectedrecord);
      var name = sessionStorage.getItem("zdr");
      if (this.edit_ok == "edit_ok") {
        // 修改
        this.axios
          .post(
            this.$store.state.baseurl + "/wxapi/smt_bjdedit.php",
            qs.stringify({
              fplx: this.zzl_val,
              hl: this.sl_val,
              dwmc: this.khmckews_val,
              dwbh: this.dwbh,
              bjdh: this.bjdh,
              rwr: this.rwr_val,
              zdr: name,
              gsbm: this.gsbm,
              bz: this.bzxx,
              bjData: bjData,
              token: sessionStorage.getItem("smt_token")
            })
          )
          .then(res => {
            console.log(res);
            if (res.data.code == 103) {
              this.$store.state.selectedrecord = [];
              this.getbjdList(this.pagination);

              this.addnew_flag = false;
              this.$notification["success"]({
                message: "成功",
                description: res.data.msg
              });
              this.spxx_index = "1-1";
            } else {
              this.$notification["error"]({
                message: "失败",
                description: res.data.msg
              });
            }
          });
      } else {
        // 新增
        this.axios
          .post(
            this.$store.state.baseurl + "/wxapi/smt_bjdinsert.php",
            qs.stringify({
              fplx: this.zzl_val,
              hl: this.sl_val,
              dwmc: this.khmckews_val,
              dwbh: this.dwbh,
              rwr: this.rwr_val,
              zdr: name,
              gsbm: this.gsbm,
              bz: this.bzxx,
              bjData: bjData,
              token: sessionStorage.getItem("smt_token")
            })
          )
          .then(res => {
            console.log(res);
            if (res.data.code == 103) {
              this.$store.state.selectedrecord = [];
              this.getbjdList(this.pagination);

              this.addnew_flag = false;
              this.$notification["success"]({
                message: "成功",
                description: res.data.msg
              });
            } else {
              this.$notification["error"]({
                message: "失败",
                description: res.data.msg
              });
            }
          });
      }
    },
    // khmcclick(rwr){
    //   console.log(rwr)
    // },
    //打印
    print(item, index) {
      console.log(item);
      this.print_flag = true;
      this.axios
        .post(
          this.$store.state.baseurl + "/wxapi/smt_bjdeditselect.php",
          qs.stringify({
            token: sessionStorage.getItem("smt_token"),
            bjdh: item.bjdh
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 103) {
            this.print_data = res.data.result;
            this.print_data.listdata = item;
            console.log(this.print_data);
          }
        });
    },
    actionbtn(item, index) {
      var that = this;
      this.axios
        .post(
          this.$store.state.baseurl + "/wxapi/smt_implement.php",
          qs.stringify({
            djbh: item.bjdh,
            gsbm: this.gsbm,
            token: sessionStorage.getItem("smt_token"),
            type: "BJD"
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 103) {
            this.getbjdList(this.pagination);
            this.$notification["success"]({
              message: "成功",
              description: res.data.msg
            });
          } else {
            this.$notification["error"]({
              message: "失败",
              description: res.data.msg
            });
          }
        });
    },
    editbjdlist(item, index, edit_ok) {
      this.edit_ok = edit_ok;
      console.log(this.edit_ok);
      this.addnew_flag = true;
      this.axios
        .post(
          this.$store.state.baseurl + "/wxapi/smt_bjdeditselect.php",
          qs.stringify({
            token: sessionStorage.getItem("smt_token"),
            bjdh: item.bjdh
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 103) {
            if (res.data.result.publicData.SL == "3.00") {
              this.zzl_val = "增值税普通发票";
            } else if (res.data.result.publicData.SL == "13.00") {
              this.zzl_val = "增值税专用发票";
            } else {
              this.zzl_val = "未税";
            }
            this.publicData = res.data.result;
            this.sl_val = res.data.result.publicData.SL;
            this.khmckews_val = res.data.result.publicData.DWMC;
            this.dwbh = res.data.result.publicData.DWBH;
            this.rwr_val = res.data.result.publicData.RWR;
            this.bzxx = res.data.result.publicData.BZ;
            for (var i = 0; i < res.data.result.bjData.length; i++) {
              res.data.result.bjData[i].id = i;
            }
            this.$store.state.selectedrecord = res.data.result.bjData;
            this.bjdh = res.data.result.bjdh;
            //    BZ: "1111"
            // DWBH: "200917-106975KHBBL"
            // DWMC: "123456"
            // RWR: "王圣磊"
            // SL: "13.00"
          }
        });
    },
    getkhdacx(page, keywords) {
      this.axios
        .post(
          this.$store.state.baseurl +
            "/wxapi/smt_khdacx.php?page=" +
            page +
            "&gsbm=" +
            this.gsbm,
          qs.stringify({
            rwrall: this.rwr,
            khmc: this.khmckews,
            token: sessionStorage.getItem("smt_token")
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.result.length) {
            this.khmclist = res.data.result;
          } else {
            this.khmclist = [];
          }
        });
    },
    selesplist() {
      console.log("111111");
      this.spxx_flag = true;
      this.sp_inp_flag = false;
    },
    getjldwlist() {
      this.axios
        .post(
          this.$store.state.baseurl + "/wxapi/smt_publicDataList.php",
          qs.stringify({
            keywords: "",
            token: sessionStorage.getItem("smt_token"),
            mc: "计量单位"
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 103) {
            this.jldwlist = res.data.result;
          }
        });
    },
    jldwChange(value) {
      console.log(`selected ${value}`);
    },
    // handleBlur() {
    //   console.log("blur");
    //   this.khmckews =""
    //     this.getkhdacx(1);

    // },
    // handleFocus() {
    //   console.log("focus");
    // },
    filterOption(input, option) {
      return (
        option.componentOptions.children[0].text
          .toLowerCase()
          .indexOf(input.toLowerCase()) >= 0
      );
    },

    khmcchan(value) {
      console.log(`selected ${value}`);
        this.khmc_keywords = value;
        this.getbjdList(this.pagination);
    },
    khmcsec(value) {
      console.log(`selected ${value}`);
        this.khmckews = value;
        this.getkhdacx(1);
    },

    getgsbm() {
      let bjdzzdata = JSON.parse(sessionStorage.getItem("bjdzzdata"));
      if (bjdzzdata.length > 1) {
        this.bjdzzdata = bjdzzdata;
        this.bjdzzdata.unshift("查所有");
      } else {
        this.bjdzzdata = [];
        console.log(this.bjdzzdata);
      }
      this.getbjdList(this.pagination);
    },
    //税率
    getSl() {
      var that = this;
      this.axios
        .post(
          "https://yb.bearing.cn/wxapi/smt_getSl.php",
          qs.stringify({
            token: sessionStorage.getItem("smt_token")
          })
        )
        .then(res => {
          if (res.data.code == 103) {
            this.sl_data = res.data.result;
          }
        });
    }
  },
  components: {
    headercom,
    spxx,
    rightnav,
    print
  },
  created() {
    //   var reg = new RegExp('|',"g");//g,表示全部替换。

    var rwr = sessionStorage.getItem("xsuser");
    console.log(rwr);

    this.gsbm = sessionStorage.getItem("gsbm");
    this.gsbm_val = sessionStorage.getItem("gsbm");

    this.rwr = rwr.split("|");
    if (this.rwr.length > 1) {
      this.rwr.unshift("请选择");
    }
    // this.rwr =  this.rwr+"";

    // console.log(this.rwr[]);

    // this.rwr=sessionStorage.getItem("xsuser")
    this.getbjdList(this.pagination);
    this.getkhdacx(1);
    this.getjldwlist();
    this.getgsbm();
    this.getSl();
  }
};
</script>

<style lang='less' scoped>
.bjdhed {
  .hedlist {
    position: fixed;
    z-index: 999;
    width: 71%;
    left: 10%;
    top: 50px;
    height: 90px;
    line-height: 60px;
    background-color: #f3f7f9;
    .head_box {
      width: 100%;
      display: flex;
      // justify-content: space-around;
      background-color: #fff;
      .headbtn {
        margin: 0 20px;
      }
      .sele {
        // margin-bottom: 15px;
        margin: 0 20px;
        text-align: center;
        position: relative;
        .sele_input {
          width: 170px;
        }
        .ant-select-auto-complete.ant-select .ant-input {
          height: 32px !important;
        }
        .ant-btn-lg {
          height: 32px !important;
        }
      }
    }
    .sear_ico {
      position: absolute;
      right: 10px;
      top: 22px;
      display: inline-block;
      font-size: 17px;
      color: #999;
    }
  }
}

.bjdzz_box {
  width: 100%;
  position: relative;
  left: 1%;
  top: 140px;
  width: 98%;
  text-align: left;
  padding: 20px;
  background: #fff;
  // .ant-tabs-bar{
  //   margin: 0!important;
  // }
}
// .left_bcg {
//      width: 70%!important;
//     left: -4%!important;
//   display: inline-block!important;
// }
.textarea_box {
  text-align: left;
  padding: 0 20px;
  ul {
    li {
      text-align: left;

      .inp_tit {
        display: inline-block;
        width: 12%;
        text-align: left;
        padding-left: 20px;
        // padding: 0 20px;
      }
      .textarea {
        width: 88%;
      }
    }
  }
}
.addnew_box {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 1000px;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  .bjd_tk {
    position: absolute;
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 57%;
    height: 600px;
    background: #fff;
    .ant-tabs-bar {
      margin-bottom: 0;
      border: 0;
    }
    .cz_title {
      display: block;
      width: 13%;
      color: #1890ff;
      text-align: center;
    }
    .cz_title_border {
      display: inline-block;
      width: 13%;
      height: 2px;
      background-color: #1890ff;
    }
    .inpt_box {
      text-align: left;
      padding: 0px 20px 0;
      // display: inline-block;
      width: 100%;
      ul {
        li {
          margin: 10px 0;
          display: inline-block;
          width: 50%;
          .inp_tit {
            display: inline-block;
            width: 24%;
            text-align: left;
            padding-left: 20px;
          }
          .ant-select-auto-complete.ant-select .ant-select-search--inline {
            margin: 0;
          }
        }
      }
    }
    .spxx_box {
      text-align: left;
      padding: 0 20px;
      // display: inline-block;
      width: 100%;
      vertical-align: top;
      .tit_p {
        margin-top: 20px;
        background: #f1f1f1;
        padding: 10px 20px;
      }
      .spxx_list_data {
        ul {
          overflow-y: scroll;
          max-height: 180px;
          // min-height: 180px;
          li {
            border-bottom: 1px solid #f1f1f1;
            padding: 5px 0px;
            margin: 0 15px;
            display: -webkit-box;
            display: -ms-flexbox;
            // display: flex;
            // -webkit-box-pack: justify;
            // -ms-flex-pack: justify;
            // justify-content: space-between;
            -webkit-box-align: center;
            -ms-flex-align: center;
            align-items: center;
            p {
              margin: 0;
            }
            .center {
              width: 20%;
              text-align: left;
            }
            // 溢出隐藏公共
            .yc {
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
            }
            .spmc_yc {
              width: 70px;
            }
            .ymInfo_yc {
              width: 25%;
            }
            .zw_p {
              text-align: center;
              line-height: 100px;
              // box-shadow: 0 0 5px #ccc;
              color: #999;
              cursor: pointer;
            }
            .cenedit {
              width: 14%;
              text-align: right;
              // display: flex;
              // justify-content: space-between;
              .cz_style {
                font-size: 14px;
                color: #1890ff;
              }
              .xx_ico {
                margin: 0 10px;
                font-size: 18px;
                cursor: pointer;
              }
            }
            .fot_mon {
              display: flex;
              justify-content: space-between;
              width: 42%;
              p {
                width: 40%;
                text-align: left;
              }
              .num_p {
                width: 60%;
              }
            }
          }
        }
      }

      .click_spxx {
        color: #1890ff;
        font-size: 16px;
        text-align: center;
        cursor: pointer;
        .bars_ico {
          font-size: 20px;
          vertical-align: top;
        }
      }
    }
  }
  @media (max-width: 1800px) {
    .bjd_tk {
      width: 60%;
      top: 3%;
    }
  }
  @media (max-width: 1500px) {
    .bjd_tk {
      width: 70%;
      top: 3%;
      // max-height: 500px;

      // height: 464px;
    }
  }
  .bjd_tit {
    text-align: left;
    padding: 40px 40px 10px;
  }
}
.sub_btn {
  text-align: center;
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  button {
    width: 130px;
    margin: 0 10px;
  }
}
</style>
